package cn.tedu.demo.controller;

import cn.tedu.demo.pojo.dto.EmpLoginDTO;
import cn.tedu.demo.pojo.dto.OrderAddNewDTO;
import cn.tedu.demo.pojo.vo.EmpVO;
import cn.tedu.demo.pojo.vo.OrderInfoListVO;
import cn.tedu.demo.service.IOrderInfoService;
import cn.tedu.demo.service.impl.AdminServiceImpl;
import cn.tedu.demo.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/orders")
@Api(tags = "1.订单版块")
public class OrderInfoController {
    @Autowired
    private IOrderInfoService orderInfoService;



    @PostMapping("/add-new")
    @ApiOperation("1.新增订单")
    @ApiOperationSupport(order = 100)
    public JsonResult<Void> login( OrderAddNewDTO orderAddNewDTO, HttpSession session ){
        log.debug("开始处理【新增订单】的请求，参数：{}",orderAddNewDTO);
        orderInfoService.addNew(orderAddNewDTO,session);
        return JsonResult.ok();
    }

    @GetMapping("/orderList")
    @ApiOperation("2.查看订单")
    @ApiOperationSupport(order = 200)
    public JsonResult<List<OrderInfoListVO>> list(HttpSession session){
        log.debug("开始处理【查询订单】的请求，参数：{}",session);
        List<OrderInfoListVO> list = orderInfoService.listByOrderTel(session);
        return JsonResult.ok(list);
    }

}
